home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / autolib / auto_load_data.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-18  |  4.2 KB  |  135 lines

  1. /*------------------------------------------------------------------------------
  2. ### loading AUTO86 output into physical memory (data2) and display ###
  3. --------------------------------------------------------------------------------
  4. Note:    -Display is on combined space box (auxiliary window)
  5.     -The ouput of AUTO86 to the standard ouput is modified and looks like,
  6.  
  7.  %ACkey x x x x param[auto_icp[0]] vaxis (param[i],i=1,auto_n1-1) (auto_option=1)
  8.  %ACkey x x x x param[auto_icp[0]] vaxis (var[i],i=0,auto_n2-1) (auto_option=2)
  9.  %ACkey x x x x param[auto_icp[0]] vaxis (var[i],i=0,auto_n2-1) (param[i],i=1,auto_n1-1) (auto_option=3)
  10.  
  11.     -All initilizations for auto pipe process are handled by auto_p_go_proc.c
  12.     Mapping: (kaos) auto_icp[i] = icp[i]-1 (AUTO86) because of difference
  13.     in indexing scheme between C and Fortran
  14. ------------------------------------------------------------------------------
  15. */
  16.  
  17. #include <stdio.h>
  18. #include <suntool/sunview.h>
  19.  
  20. auto_load_data(fp)
  21. FILE *fp;
  22. {
  23.     int i,lock_interval_old,color_index,color,s_type,s_size,aux_win_i,t_mode;
  24.     char s_key[10], s_key2[3];
  25.     extern int stop,lock_interval,symbol_size,dot_size,var_dim,full_dim,param_dim,big_length;
  26.     extern char lstring[];
  27.     extern double *t_va;
  28.     /* AUTO86 declerations */
  29.     extern int auto_option,auto_ibr,auto_ntot,auto_itp,auto_lab,auto_icp[],auto_n1,auto_n2;
  30.     extern Pixwin **aux_pw;
  31.  
  32.     /* Temporarily set lock_interval to 0 (no locking) during piping */
  33.     lock_interval_old = lock_interval;
  34.     lock_interval = 0;    
  35.  
  36.     stop = 0;
  37.     while ((fgets(lstring,big_length, fp)) != NULL) {
  38.         sscanf(lstring,"%s",s_key);
  39.         if(strcmp(s_key,"%%AS") == 0){
  40.             system_mess_proc(0,"Reading AUTO86 header...");
  41.             auto_load_param(fp);
  42.  
  43.             fscanf(fp,"%s",s_key);
  44.             if(strcmp(s_key,"%%AE") !=0){
  45.                 system_mess_proc(1,"Header NOT in the right format!");
  46.                 return;
  47.             }
  48.             else {
  49.                 /* Successful reading of a header */
  50.                 system_mess_proc(0,"Successfully read AUTO86 header! Continue...");
  51.                 break;
  52.             }
  53.         }
  54.     }
  55.     /* read data in three different formats */
  56.     auto_option = (int) get_auto_option();
  57.  
  58.     t_mode = (int) get_available_aux_window(&aux_win_i);
  59.     /* this subroutine should always come after aux_win_i is
  60.     chosen by get_availabel_aux_window() */
  61.     /* this subroutine should always come after parameters
  62.     are set by auto_translate_param() */ 
  63.     switch(t_mode){
  64.         case 0:
  65.             auto_translate_param(aux_win_i);
  66.             aux_refresh(aux_win_i);
  67.             break;
  68.         case 1:
  69.             /* translation of paramters done by
  70.             create_aux_windows */
  71.             (void) create_aux_windows(aux_win_i);
  72.             break;
  73.         case 2:
  74.             /* translation of paramters done by
  75.             create_aux_windows */
  76.             (void) destroy_aux_windows(aux_win_i);
  77.             (void) create_aux_windows(aux_win_i);
  78.             break;
  79.         default:
  80.             auto_translate_param(aux_win_i);
  81.             aux_refresh(aux_win_i);
  82.             break;
  83.     }    
  84.  
  85.     system_mess_proc(0,"Start reading AUTO86 data...");
  86.     /* read the data */
  87.     while (fscanf(fp,"%s",s_key) != EOF) {
  88.         if (strncmp(s_key, "%AC", 3) == 0) {
  89.             /* determine colors from keys */
  90.             /*
  91.             i = 0;
  92.             while ((s_key2[i] = s_key[i + 3]) != '\0')
  93.                 i++;
  94.             color_index = (int) atoi(s_key2);
  95.             */
  96.             /* Determine colors from AUTO86 parameters */
  97.             auto_get_color_symbol(&color,&s_type);
  98.             for(i=0;i<full_dim+param_dim;i++) t_va[i] = 0;
  99.  
  100.             fscanf(fp,"%d %d %d %d  %lg %lg",&auto_ibr,&auto_ntot,&auto_itp,&auto_lab,&t_va[full_dim+auto_icp[0]],&t_va[full_dim-1]);
  101.             if(auto_option==1){
  102.                 for(i=1;i<auto_n1;i++) fscanf(fp,"%lg",&t_va[full_dim+auto_icp[i]]);
  103.             }
  104.             else if(auto_option==2){
  105.                 for(i=0;i<auto_n2;i++) fscanf(fp,"%lg",&t_va[i]);
  106.             }
  107.             else if(auto_option==3){
  108.                 for(i=0;i<auto_n2;i++) fscanf(fp,"%lg",&t_va[i]);
  109.                 for(i=1;i<auto_n1;i++) fscanf(fp,"%lg",&t_va[full_dim+auto_icp[i]]);
  110.             }
  111.  
  112.             /* Piped data from AUTO86 are drawn always since one
  113.             of aux_win_mode[aux_win_i] is always turned on
  114.             when reading the AUTO86 data */
  115.             s_size = (s_type>=0) ? symbol_size : dot_size;
  116.  
  117.             pen_down(2,aux_pw[aux_win_i],t_va,color,s_type,s_size,0);
  118.  
  119.  
  120.             /* Piped data from AUTO86 are recorded always since 
  121.             region_index is always set to 2 
  122.             when reading the AUTO86 data */
  123.             encode_color_symbol(&color_index,color,s_type);
  124.             record_data(t_va,color_index);
  125.         }
  126.         if (stop) {
  127.             break;
  128.         }
  129.     }
  130.     all_refresh();
  131.  
  132.     lock_interval = lock_interval_old;
  133.     system_mess_proc(0,"Done!");
  134. }
  135.